package com.atguigu.javase;

/**
 * @Author: shenhao
 * @CreatTime: 2024/10/4 15:32
 * @Version: 1.0
 * Integer包装类新版本有变化, 8->17
 */
public class Integer_BugDemo {
    public static void main(String[] args) {
        //Integer i = new Integer(22);// 过期的方法,并标记清除
        Integer i = Integer.valueOf(20);
        System.out.println(i);
        Integer a = Integer.valueOf(600);
        Integer b = Integer.valueOf(600);
        int c = 600;
        System.out.println(a==b); //false
        System.out.println(a.equals(b));//true
        System.out.println(a==c);// true  自动拆箱
        System.out.println("-----------------------");
        // -128 - 127 缓存池 Integer Cache
        Integer x = Integer.valueOf(20);
        Integer y = Integer.valueOf(20);
        System.out.println(x==y);//true
        System.out.println(x.equals(y));//true
    }
}
